<template>
    <div class="item">
        <div class="header">
            <p>图片数量：{{ currentAlbum.pictureCount }}张
                <el-dropdown trigger="click" class="dropdown" >
                    <span class="el-dropdown-link">
                        <i class="el-icon-arrow-down el-icon--right"></i>
                    </span>
                    <el-dropdown-menu slot="dropdown">
<!--                      <button  @click="$router.push('/home/product/editalbum')">-->
                      <router-link :to="`/home/product/editalbum/${currentAlbum.id}`">
                        <el-dropdown-item  >
                           <i class="el-icon-edit" ></i>
                            编辑相册
                        </el-dropdown-item>
                      </router-link>
<!--                      </button>-->

                      <el-dropdown-item   @click.native="deletealbum">
                            <i class="el-icon-delete"></i>
                            删除相册
                      </el-dropdown-item>

                    </el-dropdown-menu>
                </el-dropdown>
            </p>
        </div>
        <div class="content">
            <router-link :to="`albummanage/${currentAlbum.id}`">
                <img :src="`${currentAlbum.cover}`" alt="" >
            </router-link>
        </div>
        <div class="footer">
            {{currentAlbum.name}}
        </div>
    </div>
</template>

<script>


export default {

    props: ['currentAlbum'], // 自定义属性currentAlbum接收当前相册对象
    methods: {
        deletealbum(){
         var  id = this.currentAlbum.id;
         this.albumApi.delete(id).then((res)=>{
           this.$alert(res.data.message);
           this.$parent.loadAlbums();
         })
      }
  }


}
</script>

<style scoped>
    .item {
        width: 200px; 
        height:200px; 
        border:1px solid #ccc;
        margin: 30px 0px 0px 30px; 
        display: inline-block;           
        background-color: #fff;                        
    }
    .item .header{
        border-bottom: 
        1px solid #ccc;
        height: 30px; 
        line-height: 30px; 
        padding: 0px 8px;
        font-size:0.9em;
    }
    .item .content {
        text-align: center;
        height: 140px;
        border-bottom: 1px solid #ccc;
    }
    .item .content img{
        height: 140px;
    }
    .item .footer{
        height: 30px; 
        text-align: center;
        line-height: 30px;
        font-size: 0.9em;
    }
    .item .header .dropdown{
        float: right;
    }
    .el-dropdown-link {
        cursor: pointer;
    }
    .el-icon-arrow-down {
        font-size: 12px;
    }

</style>
